<template>
	<view class="info">
		<u-navbar :border-bottom="false" title="基本信息"></u-navbar>
		<view class="list">
			<view class="item acea-row row-middle row-between">
				<view class="left">头像</view>
				<my-upload width="128" height="128" upload-text="上传" :action="action" name="zyfile" :file-list="[{url:info.headimg}]" addBtnIconSize="30" :max-count='1' :show-progress="false" @success="uploadSuccess"></my-upload>
			</view>
			<view class="item acea-row row-middle row-between">
				<view class="left">姓名</view>
				<u-input input-align='right' v-model="info.truename" height='44' placeholder="请输入姓名" :custom-style="{fontSize:'32rpx',color:'#000000'}"/>
			</view>
			<view class="item acea-row row-middle row-between">
				<view class="left">性别</view>
				<u-input input-align='right' v-model="info.gender" disabled @click="showGender = true" height='44' placeholder="请选择性别" :custom-style="{fontSize:'32rpx',color:'#000000'}"/>
			</view>
			<view class="item acea-row row-middle row-between">
				<view class="left">手机号</view>
				<u-input input-align='right' v-model="info.mobile" height='44' placeholder="请输入手机号" :custom-style="{fontSize:'32rpx',color:'#000000'}"/>
			</view>
			<view class="item acea-row row-between">
				<view class="left">授课科目</view>
				<view class="right acea-row row-bottom row-column">
					<text class="className" v-for="(item,index) in info.bjname" :key="index">{{item}}</text>
				</view>
			</view>
		</view>
		<u-picker mode="selector" v-model="showGender" :range="genderList" @confirm="idx=>{info.gender = genderList[idx]}"></u-picker>
		<view class="footer">
			<view class="btn" @click="submit">修改信息</view>
		</view>
	</view>
</template>

<script>
	import common from '../../../api/common.js'
	import request from '../../../api/request.js'
	const app = getApp()
	export default{
		data(){
			return{
				action:app.globalData.uploadUrl.touxiang,
				showGender:false,
				genderList:['男','女'],
				info:{},
			}
		},
		created() {
			this.getTeacherInfo()
		},
		methods:{
			submit(){
				let data = {
					name:this.info.truename,
					sex:this.info.gender == "男"?1:2,
				}
				if(this.info.imgId){
					data.headimg = this.info.imgId
				}
				request.go((e)=>{
					uni.showToast({
						icon:"success",
						title:"修改成功",
						duration:600
					})
					setTimeout(()=>{
						uni.navigateBack({})
					},600)
				},"/Jwteacher/editmsg",data,"POST")
			},
			getTeacherInfo(){ //获取老师详细信息
				request.go((e)=>{
					e.data.gender = e.data.sex == 1?"男":"女"
					e.data.headimg = app.globalData.baseUrl + e.data.headimg
					this.info = e.data
				},"/Jwteacher/teacherinfo",{},"POST")
			},
			uploadSuccess(e){
				this.info.imgId = e.id
				console.log(e)
			}
		}
	}
</script>

<style scoped>
	.info{
		min-height: 100vh;
		background-color: #F7F8FA;
	}
	.info .list{
		width: 686rpx;
		background-color: #FFFFFF;
		margin: 32rpx auto 0;
		border-radius: 24rpx;
	}
	.info .list .item{
		padding: 32rpx;
		box-sizing: border-box;
	}
	.info .list .item .left{
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		color: #1f2329;
		line-height: 44rpx;
	}
	.info .list .item image{
		display: block;
		width: 144rpx;
		height: 144rpx;
	}
	.info .list .item .right{
		font-size: 32rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		color: #000000;
		line-height: 44rpx;
	}
	.info .list .item .right .className{
		margin-bottom: 16rpx;
	}
	.info .footer{
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
		height: 120rpx;
		background-color: #FFFFFF;
		z-index: 999;
	}
	.info .footer .btn{
		width: 622rpx;
		height: 72rpx;
		line-height: 72rpx;
		text-align: center;
		margin: 24rpx auto 0;
		font-size: 28rpx;
		font-family: PingFang SC, PingFang SC-Regular;
		font-weight: 400;
		color: #ffffff;
		z-index: 99;
		background-color: #1661FF;
	}
</style>
